package com.im.session.service;

import com.im.session.JedisManager;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

/**
 * @Created leijun
 * @Date 2021/11/8 10:46 下午
 */
@Service
public class SessionService {

    private Jedis jedis = JedisManager.getJedis();

    /**
     * 创建单聊session
     * @param user1
     * @param user2
     * @return
     */
    public String createSingleSession(Long user1, Long user2) {
        String sessionkeySuffix = user1 > user2 ? user1+"_"+user2 : user2+"_"+user1;
        return "single_" + sessionkeySuffix;
    }

    /**
     * 创建群聊session
     * @param senderId
     * @param groupId
     * @return
     */
    public String createGroupSession(Long senderId, Long groupId) {
        return "group_" + groupId;
    }
}
